<<<<<<< HEAD

=======
import axios from 'axios'
>>>>>>> f425cfb0320ced29f9e28f379fa4c77eebf50d68
import type { BackendResponse } from "@/types/file";
import request from '@/utils/request';

interface UploadFileParams {
    file: File;
    uploader:string;
}

export function uploadFile(file: FormData): Promise<BackendResponse> {
<<<<<<< HEAD
    return request.post('/api/upload', file, {

        onUploadProgress: (event) => {
            const progress = event.total ? Math.round((event.loaded / event.total) * 100) : 0;
            console.log(`上传进度: ${progress}%`);
        }
    })
        .then(res => res.data)
        .catch(err => {
            console.error('上传失败', err);
            throw err;
        });
=======
    return axios.post('/api/upload',file, {
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        onUploadProgress: (event) => {
            const progress = event.total ? Math.round((event.loaded / event.total)*100) :0;
            console.log(`上传进度: ${progress}%`)
        }
    })
    .then(res => res.data)
        .catch(err => {
            console.error('上传失败',err)
            throw err
        })
>>>>>>> f425cfb0320ced29f9e28f379fa4c77eebf50d68
}
export interface BackendResponse1 {
    code:number;
    message:string;
    data: {
        fileName:string;
        filePath:string;
        fileId:string;
    };
}
